package com.gpframework.module.process.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.annotation.Excel;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.process.domain.GpProcessDeliveryNote;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpProcessDeliveryNoteReq
 * @Author gpframework
 * @Date 2023-12-20
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpProcessDeliveryNoteReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("缺货报库存申请表id")
     private Long productionApplicationId;
     @ApiModelProperty("排单表id")
     private Long processSchedulingId;
     @ApiModelProperty("发货日期")
     private Date sendOutGoodsTime;
     @ApiModelProperty("发货日期（）")
     private Date sendOutGoodsStartTime;
     @ApiModelProperty("发货日期")
     private Date sendOutGoodsEndTime;
     @ApiModelProperty("加工商ID")
     private Long processorId;
     @ApiModelProperty("加工商")
     private String processor;
     @ApiModelProperty("缸号")
     private String dyeVatNo;
     @ApiModelProperty("成品品名")
     private String productName;
     @ApiModelProperty("成品颜色")
     private String productColor;
     @ApiModelProperty("条数")
     private Long numberItems;
     @ApiModelProperty("打码规格（足码）")
     private Long codingSpecificationsSufficient;
     @ApiModelProperty("打码规格（空码）")
     private Long codingSpecificationsEmpty;
     @ApiModelProperty("总码数（空）")
     private Long totalSizeEmpty;
     @ApiModelProperty("总码数（足）")
     private Long totalSizeSufficient;
     @ApiModelProperty("大小条")
     private Long sizeBar;
     @ApiModelProperty("包数")
     private Long packNum;
     @ApiModelProperty("实际到货条数")
     private Long actualArrivalQuantity;
     @ApiModelProperty("实际规格")
     private String actNorms;
     @ApiModelProperty("是否来料： 0否 1是")
     private String incomingFlag;
     @ApiModelProperty("跟单员id")
     private Long documentaryId;
     @ApiModelProperty("跟单员")
     private String documentaryMan;
     @ApiModelProperty("收货人id")
     private Long receiverId;
     @ApiModelProperty("收货人")
     private String receiverMan;
     @ApiModelProperty("操作时间")
     private Date operateTime;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
     @ApiModelProperty("更新者")
     private String updateBy;
     @ApiModelProperty("更新时间")
     private Date updateTime;
     @ApiModelProperty("删除标记;0未删除。1已删除。")
     private Integer delStatus;
    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;

    @ApiModelProperty("实收大小条")
    private Long realitySizeBar;

    /** 操作人名称 */
    private String operatorName;
    /** 操作人编号 */
    private String operatorNum;

    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpProcessDeliveryNote> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
            lqw.orderByDesc(alias+"create_time");
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.like(alias+"sn" ,this.getSn());
        }
        if (this.getProductionApplicationId() != null){
        lqw.eq(alias+"production_application_id" ,this.getProductionApplicationId());
        }
        if (this.getProcessSchedulingId() != null){
        lqw.eq(alias+"process_scheduling_id" ,this.getProcessSchedulingId());
        }
        if (this.getSendOutGoodsTime() != null){
        lqw.eq(alias+"send_out_goods_time" ,this.getSendOutGoodsTime());
        }
        if (this.getSendOutGoodsStartTime() != null){
            lqw.apply("DATE_FORMAT(gp.send_out_goods_time, '%Y-%m-%d') >= '" + DateUtils.dateTime(this.getSendOutGoodsStartTime()) + "'");
        }
        if (this.getSendOutGoodsEndTime() != null){
            lqw.apply("DATE_FORMAT(gp.send_out_goods_time, '%Y-%m-%d') <= '" + DateUtils.dateTime(this.getSendOutGoodsEndTime()) + "'");
        }
        if (this.getProcessorId() != null){
        lqw.eq(alias+"processor_id" ,this.getProcessorId());
        }
        if (StringUtils.isNotBlank(this.getProcessor())){
        lqw.like(alias+"processor" ,this.getProcessor());
        }
        if (StringUtils.isNotBlank(this.getDyeVatNo())){
        lqw.like(alias+"dye_vat_no" ,this.getDyeVatNo());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getProductColor())){
        lqw.like(alias+"product_color" ,this.getProductColor());
        }
        if (this.getNumberItems() != null){
        lqw.eq(alias+"number_items" ,this.getNumberItems());
        }
        if (this.getCodingSpecificationsSufficient()!= null){
        lqw.eq(alias+"coding_specifications_sufficient" ,this.getCodingSpecificationsSufficient());
        }
        if (this.getCodingSpecificationsEmpty()!= null ){
        lqw.eq(alias+"coding_specifications_empty" ,this.getCodingSpecificationsEmpty());
        }
        if (this.getTotalSizeEmpty() != null){
        lqw.eq(alias+"total_size_empty" ,this.getTotalSizeEmpty());
        }
        if (this.getTotalSizeSufficient() != null){
        lqw.eq(alias+"total_size_sufficient" ,this.getTotalSizeSufficient());
        }
        if (this.getSizeBar() != null){
        lqw.eq(alias+"size_bar" ,this.getSizeBar());
        }
        if (this.getPackNum() != null){
        lqw.eq(alias+"pack_num" ,this.getPackNum());
        }
        if (this.getActualArrivalQuantity() != null){
        lqw.eq(alias+"actual_arrival_quantity" ,this.getActualArrivalQuantity());
        }
        if (StringUtils.isNotBlank(this.getActNorms())){
        lqw.eq(alias+"act_norms" ,this.getActNorms());
        }
        if (StringUtils.isNotBlank(this.getIncomingFlag())){
        lqw.eq(alias+"incoming_flag" ,this.getIncomingFlag());
        }
        if (this.getDocumentaryId() != null){
        lqw.eq(alias+"documentary_id" ,this.getDocumentaryId());
        }
        if (StringUtils.isNotBlank(this.getDocumentaryMan())){
        lqw.eq(alias+"documentary_man" ,this.getDocumentaryMan());
        }
        if (this.getReceiverId() != null){
        lqw.eq(alias+"receiver_id" ,this.getReceiverId());
        }
        if (StringUtils.isNotBlank(this.getReceiverMan())){
        lqw.eq(alias+"receiver_man" ,this.getReceiverMan());
        }
        if (this.getOperateTime() != null){
        lqw.eq(alias+"operator_time" ,this.getOperateTime());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())){
        lqw.eq(alias+"update_by" ,this.getUpdateBy());
        }
        if (this.getUpdateTime() != null){
        lqw.eq(alias+"update_time" ,this.getUpdateTime());
        }
        if (this.getDelStatus() != null){
        lqw.eq(alias+"del_status" ,this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.product_color", this.getSearchName()));
        }
        if (this.getSearchDate() != null) {
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
